<?php
namespace Entities\Corp;

use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository;

class AplicacaoRepository extends EntityRepository
{
	public function listar()
	{
		$dql	= "SELECT a FROM Entities\Corp\Aplicacao a";
		$query	= $this->getEntityManager()->createQuery($dql);

		return $query->getResult(Query::HYDRATE_OBJECT);
	}

	public function listCombo()
	{
		$return	= array();
		foreach ($this->listar() as $value)
		{
			$return[$value->getIdAplicacao()]	= $value->getDsNome();
		}
		return $return;
	}

	public function carregarTodos()
	{
		$dql = "SELECT a, pa, p
				FROM Entities\Corp\Aplicacao a
				LEFT JOIN a.perfilacoes pa
				LEFT JOIN pa.perfil p
				WHERE a.fl_status = 1";
		$query = $this->getEntityManager()->createQuery($dql);

		return $query->getResult(Query::HYDRATE_ARRAY);
	}
}